package com.lab.tools.ui;

import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cuitrip.service.R;
import com.lab.component.list.adapter.CTRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ak on 15/11/24.
 */
public class LogListAdapter extends CTRecyclerAdapter<LogView> {


    private List<HttpLog> logList = new ArrayList<>();
    private FragmentActivity context;

    public LogListAdapter(List<HttpLog> logList, FragmentActivity context) {
        this.logList = logList;
        this.context = context;
    }

    public LogView newViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.log_item, parent, false);
        LogView vh = new LogView(view, context);
        return vh;
    }

    @Override
    public void onBindViewHolder(LogView holder, int position) {
        holder.render(logList.get(position), position);
    }

    @Override
    public int getItemCount() {
        return logList == null ? 0 : logList.size();
    }
}


